#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        unordered_map<char, int> hash;

        int left = 0;
        int right = 0;
        int res = 0;
        int tmpres = 0;

        while (right < s.size())
        {
            if (hash[s[right]] != 0)
            {
                hash[s[left]] = 0;
                left++;
                tmpres--;
                continue;
            }
            hash[s[right]] = 1;
            tmpres++;
            res = max(tmpres, res);
            right++;

        }
        return res;

    }
};